<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: libemb::ProcUtil Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>libemb</b></li><li class="navelem"><a class="el" href="classlibemb_1_1_proc_util.html">ProcUtil</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classlibemb_1_1_proc_util-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">libemb::ProcUtil Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>进程工具类  
 <a href="classlibemb_1_1_proc_util.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_proc_util_8h_source.html">ProcUtil.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a9f4ff7ca969071efc780efd6801fc492"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#a9f4ff7ca969071efc780efd6801fc492">execute</a> (std::string cmd, std::string &amp;resultStr, int timeoutSec=-1)</td></tr>
<tr class="memdesc:a9f4ff7ca969071efc780efd6801fc492"><td class="mdescLeft">&#160;</td><td class="mdescRight">执行命令  <a href="classlibemb_1_1_proc_util.html#a9f4ff7ca969071efc780efd6801fc492">More...</a><br /></td></tr>
<tr class="separator:a9f4ff7ca969071efc780efd6801fc492"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae7360052de3624ee8524082805fe1d06"><td class="memItemLeft" align="right" valign="top">static std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#ae7360052de3624ee8524082805fe1d06">execute</a> (std::string cmd, int timeoutSec=-1)</td></tr>
<tr class="memdesc:ae7360052de3624ee8524082805fe1d06"><td class="mdescLeft">&#160;</td><td class="mdescRight">执行命令  <a href="classlibemb_1_1_proc_util.html#ae7360052de3624ee8524082805fe1d06">More...</a><br /></td></tr>
<tr class="separator:ae7360052de3624ee8524082805fe1d06"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3c3ecd28801cdc7dff633031c1808a9c"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#a3c3ecd28801cdc7dff633031c1808a9c">createProc</a> (std::string procName, std::string args, std::string envs, int delays=0)</td></tr>
<tr class="memdesc:a3c3ecd28801cdc7dff633031c1808a9c"><td class="mdescLeft">&#160;</td><td class="mdescRight">创建进程  <a href="classlibemb_1_1_proc_util.html#a3c3ecd28801cdc7dff633031c1808a9c">More...</a><br /></td></tr>
<tr class="separator:a3c3ecd28801cdc7dff633031c1808a9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab9b8121401278a5a556ad6e6c4ceaa61"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#ab9b8121401278a5a556ad6e6c4ceaa61">killProc</a> (std::string procName)</td></tr>
<tr class="memdesc:ab9b8121401278a5a556ad6e6c4ceaa61"><td class="mdescLeft">&#160;</td><td class="mdescRight">杀死进程  <a href="classlibemb_1_1_proc_util.html#ab9b8121401278a5a556ad6e6c4ceaa61">More...</a><br /></td></tr>
<tr class="separator:ab9b8121401278a5a556ad6e6c4ceaa61"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a386d8373b46212972b378abbf23c3baa"><td class="memItemLeft" align="right" valign="top">static std::vector&lt; int &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#a386d8373b46212972b378abbf23c3baa">getPidsByName</a> (const std::string &amp;processName)</td></tr>
<tr class="memdesc:a386d8373b46212972b378abbf23c3baa"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取进程PID  <a href="classlibemb_1_1_proc_util.html#a386d8373b46212972b378abbf23c3baa">More...</a><br /></td></tr>
<tr class="separator:a386d8373b46212972b378abbf23c3baa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae6d2d94ccaeb6e1a917852bab9a12ef0"><td class="memItemLeft" align="right" valign="top">static std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#ae6d2d94ccaeb6e1a917852bab9a12ef0">getEnv</a> (const std::string &amp;name)</td></tr>
<tr class="memdesc:ae6d2d94ccaeb6e1a917852bab9a12ef0"><td class="mdescLeft">&#160;</td><td class="mdescRight">获取环境变量  <a href="classlibemb_1_1_proc_util.html#ae6d2d94ccaeb6e1a917852bab9a12ef0">More...</a><br /></td></tr>
<tr class="separator:ae6d2d94ccaeb6e1a917852bab9a12ef0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a058a51c80f02aa4a271c7fb0d07a88b7"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_proc_util.html#a058a51c80f02aa4a271c7fb0d07a88b7">setEnv</a> (const std::string &amp;name, const std::string &amp;value)</td></tr>
<tr class="memdesc:a058a51c80f02aa4a271c7fb0d07a88b7"><td class="mdescLeft">&#160;</td><td class="mdescRight">设置环境变量  <a href="classlibemb_1_1_proc_util.html#a058a51c80f02aa4a271c7fb0d07a88b7">More...</a><br /></td></tr>
<tr class="separator:a058a51c80f02aa4a271c7fb0d07a88b7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>进程工具类 </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a id="a3c3ecd28801cdc7dff633031c1808a9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3c3ecd28801cdc7dff633031c1808a9c">&#9670;&nbsp;</a></span>createProc()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::ProcUtil::createProc </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>procName</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>args</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>envs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>delays</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>创建进程 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">procName</td><td>进程名 </td></tr>
    <tr><td class="paramname">args</td><td>参数 </td></tr>
    <tr><td class="paramname">envs</td><td>环境变量 </td></tr>
    <tr><td class="paramname">delays</td><td>延时时间 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>int 成功返回RC_OK,否则返回RC_ERROR </dd></dl>

</div>
</div>
<a id="ae7360052de3624ee8524082805fe1d06"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae7360052de3624ee8524082805fe1d06">&#9670;&nbsp;</a></span>execute() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::string libemb::ProcUtil::execute </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>cmd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>timeoutSec</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>执行命令 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cmd</td><td>命令 </td></tr>
    <tr><td class="paramname">timeoutSec</td><td>超时时间(-1:等待进程退出,其他值:最长等待时间) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>std::string 命令输出结果 </dd></dl>

</div>
</div>
<a id="a9f4ff7ca969071efc780efd6801fc492"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9f4ff7ca969071efc780efd6801fc492">&#9670;&nbsp;</a></span>execute() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int libemb::ProcUtil::execute </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>cmd</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::string &amp;&#160;</td>
          <td class="paramname"><em>resultStr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>timeoutSec</em> = <code>-1</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>执行命令 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">cmd</td><td>命令 </td></tr>
    <tr><td class="paramname">resultStr</td><td>命令输出结果 </td></tr>
    <tr><td class="paramname">timeoutSec</td><td>超时时间(-1:等待进程退出,其他值:最长等待时间) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>int 成功返回RC_OK,否则返回RC_ERROR </dd></dl>

</div>
</div>
<a id="ae6d2d94ccaeb6e1a917852bab9a12ef0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae6d2d94ccaeb6e1a917852bab9a12ef0">&#9670;&nbsp;</a></span>getEnv()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::string libemb::ProcUtil::getEnv </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取环境变量 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>环境变量名称 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>std::string </dd></dl>

</div>
</div>
<a id="a386d8373b46212972b378abbf23c3baa"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a386d8373b46212972b378abbf23c3baa">&#9670;&nbsp;</a></span>getPidsByName()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt; int &gt; libemb::ProcUtil::getPidsByName </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>processName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>获取进程PID </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">processName</td><td>进程名称 </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>std::vector&lt;int&gt; 进程PID数组 </dd></dl>

</div>
</div>
<a id="ab9b8121401278a5a556ad6e6c4ceaa61"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab9b8121401278a5a556ad6e6c4ceaa61">&#9670;&nbsp;</a></span>killProc()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void libemb::ProcUtil::killProc </td>
          <td>(</td>
          <td class="paramtype">std::string&#160;</td>
          <td class="paramname"><em>procName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>杀死进程 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">procName</td><td>进程名 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a058a51c80f02aa4a271c7fb0d07a88b7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a058a51c80f02aa4a271c7fb0d07a88b7">&#9670;&nbsp;</a></span>setEnv()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void libemb::ProcUtil::setEnv </td>
          <td>(</td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>设置环境变量 </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">name</td><td>环境变量名称 </td></tr>
    <tr><td class="paramname">value</td><td>环境变量值 </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>src/<a class="el" href="_proc_util_8h_source.html">ProcUtil.h</a></li>
<li>src/ProcUtil.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
